<?php
/**
 * Created by PhpStorm.
 * User: THINK
 * Date: 2017/8/25
<<<<<<< HEAD
 * Time: 14:51
 */
namespace Admin\Controller;
use Think\Controller;
class AdvertController extends Controller {

    public function index(){

        $key = '';

        $where = '';

        if( I('keyword') ){

            $where = "a.name like '%".I('keyword')."%' ";

            $key = I('keyword');

        }

        $User = M('abc');

        $count = $User->count();

        $Page = new \Think\Page($count,C('limitPage'));

        $show = $Page->show();

        $list = $User->alias('a')->field('a.id,a.name,a.remark,a.width,a.height,a.num,b.name as names')->where("$where")->join("xyh_iteminfo as b on a.type = b.value and b.group='inputtype'",'left')->limit($Page->firstRow.','.$Page->listRows)->select();

        //  echo $User->getLastSql();exit;

        $this->assign('list',$list);

        $this->assign('key',$key);

        $this->assign('count',$count);

        $this->assign('page',$show);

        $this->display();

    }

    public function addUser(){

        $num = I('post.');

        $User = M('abc');

        $User->add($num);

        $this->redirect('index');

    }

    public function del(){

        $User = M('abc');

        $id = is_array(I('id')) ? implode(',', I('id')) : I('id');

        if ( $User->delete($id) > 0 ){

            echo 1;

        }else{

            echo 0;

        }

    }

    public function edit(){

    }

    public function label(){

        $id = I('id');

        $User = M('abc_detail');

        $list = $User->where("aid = $id" )->select();

        $num = count($list);

        $this->assign('list',$list);

        $this->assign('num',$num);

        $this->display();

    }

    public function addDetail(){

        $this->display();

    }

    public function addDetailUser(){

         $num = I('post.');

         dump($num);exit;
    }

}

